<template>
	<BaseContainer>
		<aplid-base-crud ref="crud" class="w-100" v-bind="{...theConfig,...$attrs}">
			<template v-slot:ArchivesDialog="{ row, show }">
				<Archives @refresh="handleRefresh" @rechange="handleOperate" :api="baseConfig.api" :key="show" :nowRowData="row"></Archives>
			</template>
		</aplid-base-crud>
	</BaseContainer>
</template>

<script lang="ts" setup>
import { baseConfig } from './config'
import Archives from './Archives/index.vue'
import { editConfig } from '@/views/datacenter/comprehensiveQueries/utils/index'
import { cloneDeep } from 'lodash-es'

type Props = {
  isComprehensiveQueries?:boolean
}
let props = withDefaults(defineProps<Props>(),{
  isComprehensiveQueries:false
})
let theConfig :any= ref({})
if(baseConfig){
  let defaultConfig = cloneDeep(baseConfig)
  if(props.isComprehensiveQueries){
    theConfig.value = editConfig(defaultConfig)
  }else{
    theConfig.value = baseConfig
  }
  
}

const crud = ref(null)

const handleRefresh = (query?) => {
	nextTick(() => {
		crud.value.refreshChange(query)
	})
}

const handleOperate = (type, row, title) => {
	nextTick(() => {
		crud.value.handleOperate(type, row, title)
	})
}
defineExpose({
	handleRefresh
})
</script>

<style lang="scss" scoped></style>
